package org.jeecg.modules.iot.mqtt.server.service;

import org.jeecg.modules.iot.mqtt.entity.MqttMessageJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class MessageHandlerService {
    @Autowired
    private Map<String, MqttSendCommand> commandMap;



    public void handleDeviceSendMessage(MqttMessageJson mqttMessageJson, MqttMessageJson mqttMessageJsonReturn) throws Exception {
        MqttSendCommand command = commandMap.get(mqttMessageJson.getCmd());
        if (command != null) {
            command.execute(mqttMessageJson, mqttMessageJsonReturn);
        } else {
            // 处理未找到对应的 command 实现
        }
    }
}